<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
 <head>
  <title>inputEx - Group Usage</title>

<!-- YUI CSS -->
<link rel="stylesheet" type="text/css" href="../lib/yui/reset/reset-min.css">
<link rel="stylesheet" type="text/css" href="../lib/yui/fonts/fonts-min.css">
<link rel="stylesheet" type="text/css" href="../lib/yui/container/assets/container.css"> 
<link rel="stylesheet" type="text/css" href="../lib/yui/assets/skins/sam/skin.css">

<!-- InputEx CSS -->
<link type='text/css' rel='stylesheet' href='../css/inputEx.css' />

<!-- Demo CSS -->
<link rel="stylesheet" type="text/css" href="css/demo.css"/>
<link rel="stylesheet" type="text/css" href="css/dpSyntaxHighlighter.css">

 </head>

 <body>

<p class='demoTitle'>inputEx - Group interactions</p>


<!-- Example 1 -->
<div class='exampleDiv'>

	<p class="title">Basic Group Interactions</p>
	
	<p>Toggle a field</p>

	<div class='demoContainer' id='container1'></div>

	<div class='codeContainer'>
				<textarea name="code" class="JScript">
		</textarea>
			</div>

</div>




<!-- Example 2 -->
<div class='exampleDiv'>

	<p class="title">Basic Group Interactions</p>
	
	<p>Toggle a field</p>

	<div class='demoContainer' id='container2'></div>

	<div class='codeContainer'>
				<textarea name="code" class="JScript">
		</textarea>
			</div>

</div>



<!-- YUI Library -->
<script type="text/javascript" src="../lib/yui/yahoo/yahoo-min.js"></script> 
<script type="text/javascript" src="../lib/yui/dom/dom-min.js"></script> 
<script type="text/javascript" src="../lib/yui/event/event-min.js"></script>
<script type="text/javascript" src="../lib/yui/container/container-min.js"></script>
<script type="text/javascript" src="../lib/yui/json/json-min.js"></script>


<!-- InputEx -->
<script src="../js/inputex.js"  type='text/javascript'></script>
<script src="../js/Field.js"  type='text/javascript'></script>
<script src="../js/Group.js"  type='text/javascript'></script>
<script src="../js/fields/StringField.js"  type='text/javascript'></script>
<script src="../js/fields/CheckBox.js"  type='text/javascript'></script>
<script src="../js/fields/SelectField.js"  type='text/javascript'></script>
<script src="../js/fields/EmailField.js"  type='text/javascript'></script>
<script src="../js/fields/ListField.js"  type='text/javascript'></script>
<script src="../js/fields/UrlField.js"  type='text/javascript'></script>

<script>

YAHOO.util.Event.addListener(window, 'load', function() {
	
	// Required for the UrlField
	YAHOO.inputEx.spacerUrl = "../images/space.gif";

	// Example 1
	new inputEx.Group({ 
	   parentEl: 'container1',

	   fields: [
	       {
				   type: 'boolean', // inputex type
				   inputParams: {
					    name: 'toggler',
				      value: true,
							rightLabel: 'Check this box to toggle the enabled field'
				   },
				   interactions: [
				       {
				          valueTrigger: true, // this action will run when this field value is set to true
				          actions: [
				             {
				                name: 'group1', // name of the field on which the action should run
				                action: 'disable' // name of the method to run on the field instance !
				             },
				             {
				                name: 'group2', 
				                action: 'enable'
				             }
				          ]
				       },
				       {
				          valueTrigger: false, // when set to false:
				          actions: [
				             {
				                name: 'group1', 
				                action: 'enable'
				             },
				             {
				                name: 'group2', 
				                action: 'disable'
				             }
				          ]
				       }
				   ]
				},
	       {
				   type: 'group',
				   inputParams: {
				       name: 'group1',
				       fields: [ 
									{ type: 'select', inputParams: {label: 'Title',name: 'title', selectValues: ['Mr','Mrs','Mme'] } },
									{ inputParams: {label: 'Firstname',name: 'firstname', required: true, value:'Jacques' } }, 
									{ inputParams: {label: 'Lastname',name: 'lastname', value:'Dupont' } }, 
									{ type:'email', inputParams: {label: 'Email',name: 'email'}}
							]
						}
				 },
	       {
				   type: 'group',
				   inputParams: {
						   name: 'group2',
				       fields: [
								 {type: 'url', inputParams: {label: "Website",  name: 'myUrl' } }
							 ]
				   }
				 }
	   ]
	});
	
	
	// Example 2
	new inputEx.Group({ 
	   parentEl: 'container2',

	   fields: [
	       {
						type: 'select', 
						inputParams:{ label: 'Select your country', selectValues: ["France", "USA"]},
						interactions: [
							{
								valueTrigger: "France",
								actions: [
									{
										name: "franceCitiesSelect",
										action: "show"
									},
									{
										name: "USACitiesSelect",
										action: "hide"
									},
								]
							},
							{
								valueTrigger: "USA",
								actions: [
									{
										name: "franceCitiesSelect",
										action: "hide"
									},
									{
										name: "USACitiesSelect",
										action: "show"
									},
								]
							}
						]
				 },
			   {type: 'select', inputParams: {label: 'Select your city', name: 'franceCitiesSelect', selectValues: ["Paris", "Lyon", "Marseille"]} },
			   {type: 'select', inputParams: {label: 'Select your city', name: 'USACitiesSelect', selectValues: ["NewYork", "Chicago", "LA","San Francisco"]} }
	   ]
	});
	
	
	
});

</script>

<script src="js/dpSyntaxHighlighter.js"></script>
<script language="javascript"> 
dp.SyntaxHighlighter.HighlightAll('code');
</script>

 </body>
</html>